# test_minimal.py
from fastapi import FastAPI
from contextlib import asynccontextmanager
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

@asynccontextmanager
async def lifespan(app: FastAPI):
    # print("=== 测试 lifespan 执行 ===")
    logger.info("=== 测试 lifespan 执行 ===")
    yield
    print("=== 测试应用关闭 ===")
    logger.info("=== 测试应用关闭 ===")

app = FastAPI(lifespan=lifespan)

@app.get("/")
def root():
    return {"message": "测试"}

if __name__ == "__main__":
    import uvicorn
    print("=== 开始运行测试应用 ===")
    uvicorn.run("test1:app", host="0.0.0.0", port=1603, reload=True)
